function timestampToDate(timestamp) {
  if (!timestamp) return "";
  let date = new Date(timestamp * 1000); // 时间戳需要乘以1000转换为毫秒
  let year = date.getFullYear();
  let month = date.getMonth() + 1; // 月份从0开始计数，所以需要加1
  let day = date.getDate();
  let hours = date.getHours();
  let minutes = date.getMinutes();
  let seconds = date.getSeconds();

  // 如果月份、日期、小时、分钟或秒小于10，需要在前面添加一个0
  month = (month < 10 ? "0" : "") + month;
  day = (day < 10 ? "0" : "") + day;
  hours = (hours < 10 ? "0" : "") + hours;
  minutes = (minutes < 10 ? "0" : "") + minutes;
  seconds = (seconds < 10 ? "0" : "") + seconds;

  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
const formatDate = (time) => {
  if (!time) return "";
  const date = new Date(time);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, "0"); // 月份从0开始，需要加1，并且保证两位数格式
  const day = String(date.getDate()).padStart(2, "0"); // 保证两位数格式

  return `${year}-${month}-${day}`;
};

export { timestampToDate, formatDate };
